package models

import (
	"time"
	"tuowei.com/common/models"
)

type SysStudent struct {
	models.Model
	SerialNum           string       `json:"serial_num" gorm:"type:varchar(50);not null;comment:学员编号"`
	Name                string       `json:"name" gorm:"type:varchar(50);not null;comment:学员名称"`
	CollegeId           int          `json:"college_id" gorm:"type:int(5);not null;default:0;comment:学员院校ID"`
	NickName            string       `json:"nick_name" gorm:"type:varchar(100);comment:昵称"`
	Phone               string       `json:"phone" gorm:"type:varchar(20);not null;comment:手机号码"`
	TotalPay            float32      `json:"total_pay" gorm:"type:decimal(10,2);comment:付费总额"`
	UserLabel           string       `json:"user_label" gorm:"type:varchar(50);comment:学员等级 普通/VIP/SVIP"`
	OrderCount          int          `json:"order_count" gorm:"type:int(10);comment:订单总数"`
	UserType            string       `json:"user_type" gorm:"varchar(10);comment:用户类型 线上/线下"`
	Province            int          `json:"province"`
	District            int          `json:"district" gorm:"type:int(10);comment:所属区县"`
	City                int          `json:"city" gorm:"type:int(10);comment:所属区域"`
	Area                int          `json:"area" gorm:"type:int(10);comment:所属教学点"`
	ShenBenTime         *time.Time   `json:"shen_ben_time,omitempty"`
	LastPayTime         *time.Time   `json:"last_pay_time,omitempty"`
	TeachRecommender    int          `json:"teach_recommender" gorm:"type:int(10);comment:老师推荐人ID"`
	Recommender         int          `json:"recommender" gorm:"type:int(10);comment:推荐人"`
	RmId                int          `json:"rm_id" gorm:"type:smallint(2);comment:大区经理ID"`
	RegionalMId         int          `json:"regional_m_id" gorm:"type:smallint(2);comment:区域经理ID"`
	EnrollmentTeacherId int          `json:"enrollment_teacher_id" gorm:"type:smallint(2);comment:招生老师ID"`
	ClassId             int          `json:"class_id" gorm:"type:smallint(2);comment:班级ID"`
	Source              string       `json:"source" gorm:"type:varchar(20);comment:学员来源"`
	Status              int          `json:"status" gorm:"type:tinyint(1);comment:学员状态"`
	BuyStatus           int          `json:"buy_status" gorm:"type:tinyint(1);default 1;comment:学生购买状态，1-游客，2-正式，3-结业，4-退学"`
	ProgressStatus      int          `json:"progress_status" gorm:"type:tinyint(1);not null;default:1;comment:学员跟进状态，1-刚添加的学生，2-待联系，3-待分班，4-完成"`
	ProvinceDept        *StudentDept `json:"province_dept" gorm:"foreignKey:province;references:dept_id"`
	CityDept            *CityDept    `json:"city_dept" gorm:"foreignKey:city;references:dept_id"`
	AreaDept            *AreaDept    `json:"area_dept" gorm:"foreignKey:area;references:dept_id"`
	Faculty             string       `json:"faculty" gorm:"type:varchar(20);comment:院系"`
	Major               string       `json:"major" gorm:"type:varchar(50);comment:专业"`
	College             *Colleges    `json:"college" gorm:"foreignKey:college_id;references:id"`
	Class               *SysClass    `json:"class" gorm:"foreignKey:class_id;references:id"`
	CollegeClass        string       `json:"college_class" `
	IsRegistered        int          `json:"is_registered" gorm:"type:tinyint(2);comment:是否完成注册信息填写 -1-没有完成注册信息，1-完成注册信息"`
	Score               float64      `json:"score" gorm:"-"`
	Balance             float32      `json:"balance" gorm:"type:decimal(10,2);comment:学员余额"`
	Cover               string       `json:"cover" gorm:"varchar(255);comment:头像"`
	IdCard              string       `json:"id_card" gorm:"type:varchar(50);comment:身份证ID"`
	QQ                  string       `json:"qq" gorm:"type:varchar(20);comment:QQ号"`
	EnrollmentYear      string       `json:"enrollment_year" gorm:"varchar(20);comment:入学年份"`
	StudyDuration       string       `json:"study_duration" gorm:"-"`
	Logined             string       `json:"logined" gorm:"type:varchar(64);default:;comment:是否登陆"`
	models.ModelTime
}

func (SysStudent) TableName() string {
	return "sys_student"
}

type SysStudentList struct {
	Id          int          `json:"id"`
	SerialNum   string       `json:"serial_num"`
	Name        string       `json:"name" gorm:"type:varchar(50);not null;comment:学员名称"`
	NickName    string       `json:"nick_name" gorm:"type:varchar(100);comment:昵称"`
	Phone       string       `json:"phone" gorm:"type:varchar(20);not null;comment:手机号码"`
	TotalPay    float32      `json:"total_pay" gorm:"type:decimal(10,2);comment:付费总额"`
	UserLabel   string       `json:"user_label" gorm:"type:varchar(50);comment:学员等级 普通/VIP/SVIP"`
	OrderCount  int          `json:"order_count" gorm:"type:int(10);comment:订单总数"`
	UserType    string       `json:"user_type" gorm:"tinyint(1);comment:用户类型 线上/线下"`
	Province    int          `json:"province" gorm:"type:int(10);comment:所属大区"`
	LastPayTime time.Time    `json:"last_pay_time"`
	Dept        *StudentDept `json:"dept" gorm:"foreignKey:province;references:dept_id"`
	Status      int          `json:"status" gorm:"type:tinyint(1);comment:学员状态"`
}

func (SysStudentList) TableName() string {
	return "sys_student"
}

type UpdateSysStudent struct {
	models.Model
	Name           string    `json:"name" gorm:"type:varchar(50);not null;comment:学员名称"`
	CollegeId      int       `json:"college_id" gorm:"type:int(5);not null;default:0;comment:学员院校ID"`
	Phone          string    `json:"phone" gorm:"type:varchar(20);not null;comment:手机号码"`
	Province       int       `json:"province" gorm:"type:int(10);comment:所属大区"`
	District       int       `json:"district" gorm:"type:int(10);comment:所属区县"`
	City           int       `json:"city" gorm:"type:int(10);comment:所属区域"`
	Area           int       `json:"area" gorm:"type:int(10);comment:所属教学点"`
	ShenBenTime    time.Time `json:"shen_ben_time"`
	Faculty        string    `json:"faculty" gorm:"type:varchar(20);comment:院系"`
	Major          string    `json:"major" gorm:"type:varchar(50);comment:专业"`
	IsRegistered   int       `json:"is_registered" gorm:"type:tinyint(2);comment:是否完成注册"`
	EnrollmentYear string    `json:"enrollment_year" gorm:"varchar(20);comment:入学年份"`
	CollegeClass   string    `json:"college_class" gorm:"varchar(20);comment:大学所在班级"`
	IdCard         string    `json:"id_card" gorm:"varchar(50);comment:身份证ID"`
	QQ             string    `json:"qq" gorm:"varchar(20);comment:QQ号"`
	Cover          string    `json:"cover" gorm:"varchar(255);comment:头像"`
	models.ModelTime
}

func (UpdateSysStudent) TableName() string {
	return "sys_student"
}

type PayBalanceSysStudent struct {
	models.Model
	Balance float32 `json:"balance" gorm:"type:decimal(10,2);comment:学员余额"`
}

func (PayBalanceSysStudent) TableName() string {
	return "sys_student"
}

type MyInviteStudentList struct {
	models.Model
	CollegeId int       `json:"college_id" gorm:"type:int(5);not null;default:0;comment:学员院校ID"`
	Name      string    `json:"name" gorm:"type:varchar(50);not null;comment:学员名称"`
	College   *Colleges `json:"college" gorm:"foreignKey:college_id;references:id"`
	models.ModelTime
}

func (MyInviteStudentList) TableName() string {
	return "sys_student"
}

type UpdateStudyDurationModel struct {
	StudyDuration int `json:"study_duration" gorm:"type:int(10);default:0;comment:学习时长"`
}

func (UpdateStudyDurationModel) TableName() string {
	return "sys_student"
}
